<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 5/11/2021
 * Time: 10:53 AM
 */

namespace App\Traits;

use Illuminate\Support\Facades\Cache as Ca;
//
trait Cache
{



    /**
     * 设置/获取缓存
     * @param $key
     * @param string $val 缓存值
     * @param int $exp  缓存时间 分钟
     */
    static function cache ($key, $val='', $exp=1)
    {

        if($val) {
            Ca::put($key, $val, $exp*60);
        } else {
            return Ca::get($key);
        }
    }



    static function cacheDel($key)
    {
        Ca::forget($key);
    }



}